﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CrystalDecisions.CrystalReports.Engine;
using System.Data;
using MahApps.Metro.Controls;

namespace MauThuTabControl
{
    /// <summary>
    /// Interaction logic for BCThongKeTonKho.xaml
    /// </summary>
    public partial class BCThongKeTonKho : MetroWindow
    {
        public BCThongKeTonKho()
        {
            InitializeComponent();
           
        }
        ConnectionDB cn = new ConnectionDB();
        void ShowCry() 
        {
            DataSet ds = new DataSet();
            ReportDocument rptDoc = new ReportDocument();
            rptDoc.Load(@"../../_rBCThongKeTonKho.rpt");
            //rptDoc.SetDataSource(cn.Loadtree("SELECT dbo.DMSanPham.maSanPham, dbo.DMSanPham.tenSanPham, dbo.DMNhomSP.tenNhomSP, dbo.DMHangSX.tenHSX, dbo.DMSanPham.giaBan,(ISNULL((select sum(soLuong) from QLNhapHangCT where QLNhapHangCT.maSanPham=DMSanPham.maSanPham),0)-ISNULL((select sum(soLuong) from QLXuatHangCT where QLXuatHangCT.maSanPham=DMSanPham.maSanPham),0)) as SLton FROM dbo.DMSanPham INNER JOIN dbo.DMNhomSP ON dbo.DMSanPham.maNhomSP = dbo.DMNhomSP.maNhomSP INNER JOIN dbo.DMHangSX ON dbo.DMSanPham.maHSX = dbo.DMHangSX.maHSX"));
            crystalReportsViewer1.ViewerCore.ReportSource = rptDoc;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ShowCry();
        }
    }
}
